<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <App />
    </div>
    <script src="./vue.js"></script>
    <script src="./moment.js"></script>
    <script>

        let App = {
            data() {
                return {
                    msg: "hello world",
                    time: new Date(),
                }
            },
            template: `
                <div>我是一个App  {{ msg | myReverse }}
                    <h2>{{ time | myTime('YYYY-MM-DD') }}</h2>
                </div>
            `,
            filters: {
                // 声明过滤器
                myReverse: function(val) {
                    return val.split('').reverse().join('');
                },
                // 
                myTime: function(val, formatStr) {
                    return moment(val).format(formatStr);
                },
            },
        };

        new Vue({
            el: '#app',
            data() {
                return {

                }
            },
            components: {
                App
            }
        });
    </script>
</body>
</html>